<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="./css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="./css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="./css/animate.css" rel="stylesheet">
    <link href="./css/style.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>if (window.top !== window.self) {
        window.top.location = window.location;
    }</script>
</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name"></h1>
            <img class="logo-name" src="./img/logoh.png" height="300px" width="300px"/>
        </div>
        <br/><br/><br/>
        <h3>欢迎使用A市人民医院线上平台</h3>

        <form class="m-t" role="form">

            <!-- 登录下拉框 -->
            <div class="form-group">
                <select class="form-control" id="identity">
                    <option value="1">用户</option>
                    <option value="2">医护人员</option>
                    <option value="3">管理员</option>
                </select>
            </div>

            <div class="form-group">
                <input type="email" id="account" class="form-control" placeholder="用户名" required="">
            </div>
            <div class="form-group">
                <input type="password" id="password" class="form-control" placeholder="密码" required="">
            </div>
            <button type="button" id="submit" class="btn btn-primary block full-width m-b">登 录</button>


            <p class="text-muted text-center"><a href="login.html#"><small>忘记密码了？</small></a> | <a href="register.html">注册一个新账号</a>
            </p>

        </form>
    </div>
</div>

<!-- 全局js -->
<script src="./js/jquery.min.js?v=2.1.4"></script>
<script src="./js/bootstrap.min.js?v=3.3.6"></script>
<script src="./js/index.js"></script>


</body>


<script type="application/javascript">

    $("#submit").click(function () {
        login();
    });


    function login(){

        $.ajax({
            async: true,
            type: "post",
            url: "/login",
            data: JSON.stringify(getQueryData()),
            contentType: 'application/json',
            dataType: "text",
            success: function (data) {
                var result = JSON.parse(data);
                if(result.SUCCESS){
                    window.location.href = "/index.html";
                }else{
                    alert(result.RESULT);
                }
            },
            error: function (data) {
                alert("请求失败");
            }
        });
    }


    function getQueryData() {
        var dto = {};
        if (!ifEmpty($("#identity").val())) {
            dto["identity"] = $("#identity").val().trim();
        }
        if (!ifEmpty($("#account").val())) {
            dto["account"] = $("#account").val().trim();
        }
        if (!ifEmpty($("#account").val())) {
            dto["password"] = $("#password").val().trim();
        }
        return dto;
    }





</script>


</html>
